/**
 *
 */
package com.hybris.msig.paymentgateway.populators;

import de.hybris.platform.converters.Populator;
import de.hybris.platform.servicelayer.dto.converter.ConversionException;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.hybris.msig.paymentgateway.data.PaymentResponseData;


/**
 * @author i313922
 *
 */
public class TelemoneyPaymentCallbackPopulator implements Populator<HttpServletRequest, PaymentResponseData>
{

	/*
	 * (non-Javadoc)
	 *
	 * @see de.hybris.platform.converters.Populator#populate(java.lang.Object, java.lang.Object)
	 */
	@Override
	public void populate(final HttpServletRequest source, final PaymentResponseData target) throws ConversionException
	{
		/**
		 * final String mid = request.getParameter("TM_MCode"); final String ref = request.getParameter("TM_RefNo");
		 * final String status = request.getParameter("TM_Status");
		 */
		target.setRefid(source.getParameter("TM_RefNo"));
		final String status = source.getParameter("TM_Status");
		target.setStatus("YES".equalsIgnoreCase(status) ? "PAYSUCESS" : "NO".equalsIgnoreCase(status) ? "PAYFAIL" : "UNKNOWN");
		target.setGtwAckID(source.getParameter("TM_ApprovalCode"));
		target.setMerchantBank(source.getParameter("TM_CCNum"));
		target.setGtwTimestamp(new Date());
	}

}
